package com.sz.stock.client;

import com.sz.stock.common.ResultBean;
import com.sz.stock.model.Deal;
import com.sz.stock.model.Entrust;
import com.sz.stock.model.POS;

import com.sz.stock.model.StockBuyOrSale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;

@Component
@FeignClient("stock-trading")
public interface TradingClient {


    //    查持仓用户的所有
    @RequestMapping("/trading/allPos")
    ResultBean allPos(int userid);


    /**[卖出]
     * . 卖出查 持仓 (一条数据)
     */
    @RequestMapping("/trading/selectPos")
    ResultBean selectPos(@RequestBody POS pos);

    /**卖出
     * . 卖出添加委托 (交易)
     */
    @RequestMapping("/trading/addEntrust")
    ResultBean addEntrust(Entrust entrust);


    /**
     * 1. 查询一支股票
     */
    @RequestMapping(value = "/buy/getAStock", method = RequestMethod.POST)
    ResultBean getAStock(@RequestParam(value = "code") String code);


    /**
     * 2. 修改持仓
     */
    @RequestMapping("/trading/posUpdate")
    ResultBean posUpdate(@RequestBody POS pos);

    /**
     * 3. 查询所有委托信息
     */
    @RequestMapping(value = "/trading/showEntrust")
    ResultBean showEntrust(int userid);


    /**
     * 4. 查询委托信息 (未成交 部成)
     */

    @RequestMapping("/trading/keywordEntrust")
    ResultBean keywordEntrust();


    /**
     * 5. 查询委托信息 (未成交 部成) 带分页
     */
    @RequestMapping("/trading/keywordEntrust2")
    ResultBean keywordEntrust2(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize, @RequestParam("userid") int userid, @RequestParam("stockEntrustCode") String stockEntrustCode);

    /**
     * 5.1 查询委托信息 带分页 条件查询
     */
    @RequestMapping("/trading/keywordEntrust3")
    ResultBean keywordEntrust3(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize, @RequestParam("userid") int userid, @RequestBody(required = false) Entrust entrust);


    /**
     * 6. 股票撤单
     */
    @RequestMapping("/trading/cancel")
    ResultBean cancelStock(@RequestBody ArrayList<Integer> stockEntrustIds);

    /**
     * 7. 根据委托表ID查询当前 委托信息
     */
    @RequestMapping("/trading/selectEntrustById")
    ResultBean selectEntrustById(@RequestParam("stockEntrustId") int stockEntrustId);

    /**
     * 8.修改委托
     */
    @RequestMapping("/trading/updateMoney")
    ResultBean updateMoney(@RequestBody Entrust entrust);

    /**
     * 股票撤销功能2
     * 撤全部买入 撤全部
     */
    @RequestMapping("/trading/canel2")
    ResultBean canelStock2(@RequestBody int userid);


    /**
     * 股票撤销功能3
     * 撤全部卖出
     */
    @RequestMapping("/trading/canel3")
    ResultBean canelStock3(@RequestBody int userid);

    /**
     * 查询 所有成交信息 带分页
     */
    @RequestMapping("/trading/allDeal2")
    ResultBean allDeal2(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize,@RequestParam("userid") int userid, @RequestParam("stockDealCode") String stockDealCode);

    /**
     * 获取买卖盘信息
     */
    @RequestMapping(value = "/bos/getfive",method = RequestMethod.POST)
    ResultBean getFive(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "type",required = false) String type);

    @RequestMapping("/pos/pageSearch")
    ResultBean getMyPos(@RequestParam("userid") int userid,@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize, @RequestParam("searchCode") String searchCode);

    //-------------------------------不要写在这下面了!!!-----------------------------

    /**
     * 1. 查询 卖出 委托信息(判断是否可以成交)
     */
    @RequestMapping(value = "/buy/selectSellEntrust", method = RequestMethod.POST)
    ResultBean selectSellEntrust(@RequestBody Entrust entrust);



    /**
     * 3 .添加 委托
     */
    @RequestMapping(value = "/buy/addEntrust", method = RequestMethod.POST)
    ResultBean addEntrustForBuy(@RequestBody(required = false) Entrust entrust);

    /**
     * 4. 将交易成功的买入委托加入到持仓表中
     */
    @RequestMapping(value = "/buy/addPOSForBuy", method = RequestMethod.POST)
    ResultBean addPosForBuy(@RequestBody(required = false) POS pos);

    /**
     * 5. 查询 指定股票的持仓信息
     */
    @RequestMapping(value = "/buy/getOnePos", method = RequestMethod.POST)
    POS getOnePos(@RequestParam(value = "code") String code, @RequestParam(value = "userId") Integer userId);

    /**
     * 6. 通过 委托ID 查询一个委托信息
     */
    @RequestMapping(value = "/buy/selectEntrustById", method = RequestMethod.POST)
    Entrust getOneEntrust(@RequestParam(value = "stockEntrustId") Integer stockEntrustId);

    /**
     * 7. 添加 成交表
     */
    @RequestMapping(value = "/buy/addDeal")
    ResultBean addDeal(@RequestBody(required = false) Deal deal);

    /**
     * 8. 修改委托信息
     */
    @RequestMapping(value = "/buy/updateEntrust",method = RequestMethod.POST)
    Integer updateEntrust(@RequestBody(required = false) Entrust entrust);

    /**
     * 9. 修改持仓信息
     */
    @RequestMapping(value = "/buy/updatePos",method = RequestMethod.POST)
    Integer updatePos(@RequestBody(required = false) POS pos);

    /**
     * 10. 通过合同编号查询委托信息(成交用)
     */
    @RequestMapping(value = "/buy/selectEntrustByContractID", method = RequestMethod.POST)
    Entrust selectEntrustByContractID(@RequestParam("contractID") String contractID);

    /**
     *  11. 通过 委托查询 买卖盘信息
     */
    @RequestMapping(value = "/buy/selectBos", method = RequestMethod.POST)
    StockBuyOrSale selectBos(@RequestBody Entrust entrust);

    /**
     * 12. 修改买卖盘信息
     */
    @RequestMapping(value = "/buy/updateBos")
    ResultBean updateBos(@RequestBody StockBuyOrSale stockBuyOrSale);
    // ------------------------------不要写在这上面了!!!--------------------------------
}
